package agents;

import game.constants.ReferenceAgent;
import game.constants.ReferenceObject;
import interfaces.impl.Agent;

import java.util.ArrayList;

import objects.WorldObject;
import universe.Universe;
import actions.ActionActivateObject;
import actions.ActionPickUpObject;

public class AgentRefineryVespeneGas extends Agent{
	
	ActionPickUpObject actionPickUpObject;
	ActionActivateObject actionActivateObject;

	@Override
	public void initializeActionList() {
		actionPickUpObject=new ActionPickUpObject();
		addAction(actionPickUpObject);
		
		actionActivateObject = new ActionActivateObject();
		addAction(actionActivateObject);
		
	}

	@Override
	public void initializeSpecialFeatures() {
		
		
	}

	@Override
	public void initializeName() {
		name="agent refinery vespene gas";
		
	}

	@Override
	public void initializeId() {
		id=ReferenceAgent.AGENT_REFINERY_VESPENE_GAS;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {
		
		double x1= object.getImageObject().getPosition().getX();
		double x2= object.getImageObject().getPosition().getX()+object.getImageObject().getImageToShow().getWidth();
		double y1= object.getImageObject().getPosition().getY();
		double y2= object.getImageObject().getPosition().getY()+object.getImageObject().getImageToShow().getHeight();
			
		ArrayList<WorldObject> listVespeneGas=  universe.getObjects(x1, y1, x2, y2, ReferenceObject.OBJECT_REFERENCE_VESPENE_GAS);
		for(WorldObject vespeneGas : listVespeneGas){
			actionPickUpObject = new ActionPickUpObject();
			actionPickUpObject.setSource(object);
			actionPickUpObject.setTarget(object);
			actionPickUpObject.setObjetToPickUp(vespeneGas);
			universe.setAction(actionPickUpObject);
			
			actionActivateObject= new ActionActivateObject();
			actionActivateObject.setSource(object);
			actionActivateObject.setTarget(vespeneGas);
			actionActivateObject.setActive(false);
			universe.setAction(actionActivateObject);
			
		}
		isActive=false;
		
	}
	
	

}
